#include "msg_queue_peer.h"

struct msgbuf
{
    long mtype;
    char mdata[256];
};

int main(int argc, char *argv[])
{
    struct msgbuf recv_buf;

    while (1)
    {
        if(msg_queue_recv("topic", &recv_buf, sizeof(recv_buf), 1, 0) > 0)//读取 1为modbus 2为单片机
        {
            printf("recv from msga type = %ld\n", recv_buf.mtype);
            printf("recv from msga data = %s\n", recv_buf.mdata);
        }
        else
        {
            perror("recv error:");
            return -1;
        }
    }

    return 0;
}